home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 May / chip-cd_2005_05.zip / 05 / Internet / Amaya 9.1 / Amaya 9.1 Win / amaya-WinXP-9.1.exe / amaya / HTML.trans < prev    next >
Text File  |  2004-04-21  |  11KB  |  518 lines

  1. ! Use of the file HTML.trans
  2. !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  3. ! This file can be edited during an Amaya session. It will be 
  4. ! dynamically parsed when the transformation tool is required by
  5. ! the editor. So new transformations can be added while editing.
  6. !
  7. ! Syntax of the transformation language for Amaya
  8. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  9. !
  10. ! comments begin with !
  11. !
  12. ! This file can be edited during an Amaya session. It will be 
  13. ! dynamically parsed when the transformation tool is required by
  14. ! the editor. So new transformations can be added while editing.
  15. !
  16. ! A tranformation rule has three parts : 
  17. !     - a NAME terminated by a colon ":"
  18. !     - a SOURCE PATTERN terminated by a semi-colon ";"
  19. !     - and a list of RULES between braces "{" "}", each one
  20. !       terminated by a semi-colon ";"
  21. !
  22. ! a) The NAME will appear in the transform menu.
  23. !
  24. ! b) The SOURCE PATTERN gives of a specific organization of the elements
  25. ! to be transformed: it contains XML/HTML tags and SGML-like syntax
  26. ! for the composition operators:
  27. !     e1 | e2   for a choice between elements e1 and e2
  28. !     e1 , e2   for a sequence e1 followed by e2
  29. !     e+        for a sequence of one or more elements e
  30. !     ?e        for an optional element e
  31. !     ( )       for grouping nodes
  32. ! The braces "{" "}" define the content of a node.
  33. ! The symbol "*" is a token that matches any element type
  34. ! It is possible to rename a tag by preceeding it with a name
  35. ! followed by a colon ":"
  36. !
  37. ! c) RULES express transformations to be applied to the elements 
  38. ! identified in the pattern.
  39. ! Each rule end with a symbol ";"
  40. !
  41. ! - It could be performed by an action rule. In this case the rule
  42. !   starts with a "$" followed by the menu action to be called.
  43. !
  44. ! - It could be a list of transformation items:
  45. !  They have two parts :
  46. !      - a source identifier: a tag or a name which occurs in
  47. !        the pattern and links the rule to the pattern nodes
  48. !      - a rule body: drives the transformation
  49. !        there are two kinds of rule bodies:
  50. !        - a discard rule body is slash and express that the correspoding
  51. !          pattern node does not occuring the transformation result
  52. !        - a generation rule begins with
  53. !        - a symbol ">"
  54. !        - and a target tag list. This list is itself divided into
  55. !          two parts separated by a colon":": 
  56. !           * the generation location path
  57. !           * and the list of tags to be generated
  58. !   The dot symbol "." is used for descending in the tree structure.
  59. !   if the special token star "*" ends the list of tags to be 
  60. !   generated, the source elment tag is not changed but this element
  61. !   can be moved in a different place in the destination. 
  62. !
  63. !   The rules are applied in the order the identifiers are met when
  64. !   (depth first) traversing the source structure.
  65. !   Several rules may have the same identifier, in that case, the rules
  66. !   are applied in the order they are defined.
  67.  
  68. ! Transformation rules 
  69. !!!!!!!!!!!!!!!!!!!!!!
  70.  
  71. Address:(p{*+})+;
  72.     {
  73.     * > address:*;
  74.     }
  75.  
  76. Paragraph:(address{*+});
  77.     {
  78.     * > p:*;
  79.     }
  80.  
  81. !between lists
  82. !!!!!!!!!!!!!!
  83. Definition list:*{(li{(list:*{(li2:li)+}|other:*)+})+};
  84.     {
  85.     other > dl:dt;
  86.     list > dl:dd;
  87.     li2 > dl.dd:;
  88.     }
  89.  
  90. Bulleted list:(dl{(dt|dd{(*)+})+})+;
  91.     {
  92.     dt > ul:li;
  93.     * > ul.li.ul:li.*;
  94.     }
  95.  
  96. Numbered list:(dl{(dt|dd{(*)+})+})+;
  97.     {
  98.     dt > ol:li;
  99.     * > ol.li.ol:li.*;
  100.     }
  101.  
  102. Bulleted list:(ol{(li{(*)+})+})+;
  103.         {
  104.         * > ul:li.*;
  105.         }
  106.  
  107. Numbered list:(ul{(li{(*)+})+})+;
  108.         {
  109.     * > ol:li.*;
  110.         }
  111.  
  112. Definition data:dt{(*)+};
  113.     {
  114.     * > dd:*;
  115.     }
  116.  
  117. Definition term:dd{(p|*)+};
  118.     {
  119.     dd > :dt;
  120.     p > :dt;
  121.     * > dt:*;
  122.     }
  123.  
  124. Remove definition list:(dl{(dt{(dtc:*)+}|dd{(p|*)+})+})+;
  125.     {
  126.     dtc > h4:*;
  127.     p > p;
  128.     * > p:*;
  129.     }
  130.  
  131. !flattering headings 
  132. !!!!!!!!!!!!!!!!!!!!
  133.  
  134. Paragraphs: 
  135. (h1|h2|h3|h4|h5|h6|p|*{(li{(il:*)+})+})+;
  136.     { 
  137.     h1 > :p;
  138.     h2 > :p;
  139.     h3 > :p;
  140.     h4 > :p;
  141.     h5 > :p;
  142.     h6 > :p;
  143.     p > :p;
  144.     il > :p;
  145.     }
  146.  
  147. !headings to/from definitions
  148. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  149.  
  150. Definition list:*,(h1|h2|h3|h4|h5|h6|p)+;
  151.     {
  152.     * > dl:dt;
  153.     h1 > dl:dt;
  154.     h2 > dl:dt;
  155.     h2 > dl:dt;
  156.     h3 > dl:dt;
  157.     h4 > dl:dt;
  158.     h5 > dl:dt;
  159.     h6 > dl:dt;
  160.     p > dl:dd;
  161.     }
  162.  
  163. Definition list:(h1,?hr,?(level1:*)+,?(h2,?(level2:*)+,?((h3|h4|h5|h6),(level3:*)+)+)+)+;
  164.     {
  165.     h1 > dl:dt;
  166.     level1>dl.dd:*;
  167.     h2 > dl.dd:dl.dt ;
  168.     level2 > dl.dd.dl.dd:*;
  169.     h3 > dl.dd.dl.dd:dl.dt ;
  170.     h4 > dl.dd.dl.dd:dl.dt ;
  171.     h5 > dl.dd.dl.dd:dl.dt ;
  172.     h6 > dl.dd.dl.dd:dl.dt ;
  173.     level3 > dl.dd.dl.dd.dl.dd:*;
  174.     }
  175.  
  176. Definition list:(h2,?hr,?(level1:*)+,(h3,?(level2:*)+,((h4|h5|h6),(level3:*)+)+)+)+;
  177.     {
  178.     h2 > dl:dt;
  179.     level1 > dl.dd:*;
  180.     h3 > dl.dd:dl.dt ;
  181.     level2 > dl.dd.dl.dd:*;
  182.     h4 > dl.dd.dl.dd:dl.dt ;
  183.     h5 > dl.dd.dl.dd:dl.dt ;
  184.     h6 > dl.dd.dl.dd:dl.dt ;
  185.     level3 > dl.dd.dl.dd.dl.dd:*;
  186.     }
  187.  
  188. Definition list:(h3,?hr,?(level1:*)+,?(h4,?(level2:*)+,((h5|h6),(level3:*)+)+)+)+;
  189.     {
  190.     h3 > dl:dt;
  191.     level1 > dl.dd:*;
  192.     h4 > dl.dd:dl.dt ;
  193.     level2 > dl.dd.dl.dd:*;
  194.     h5 > dl.dd.dl.dd:dl.dt ;
  195.     h6 > dl.dd.dl.dd:dl.dt ;
  196.     level3 > dl.dd.dl.dd.dl.dd:*;
  197.     }
  198.  
  199. Multi-level definition list:(h4,?hr,?(level1:*)+,(h5,?(level2:*)+,((h6)+,(level3:*)+)+)+)+;
  200.     {
  201.     h4 > dl:dt;
  202.     level1 > dl.dd:*;
  203.     h5 > dl.dd:dl.dt ;
  204.     level2 > dl.dd.dl.dd:*;
  205.     h6 > dl.dd.dl.dd:dl.dt ;
  206.     level3 > dl.dd.dl.dd.dl.dd:*;
  207.     }
  208.  
  209. Headings h1:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  210.     {
  211.     dt1 > :h1;
  212.     dt2 > :h2;
  213.     dt3 > :h3;
  214.     content > :*;
  215.     }
  216.  
  217. Headings h2:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  218.     {
  219.     dt1 > :h2;
  220.     dt2 > :h3;
  221.     dt3 > :h4;
  222.     content > :*;
  223.     }
  224.  
  225. Headings h3:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  226.     {
  227.     dt1 > :h3;
  228.     dt2 > :h4;
  229.     dt3 > :h5;
  230.     content > :*;
  231.     }
  232.  
  233. ! Preformatted to/from paragraphs
  234. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  235.  
  236. Preformatted: (p{*+})+;
  237.     {
  238.     * > pre:*;
  239.     }
  240.  
  241. Paragraph: (pre{*+})+;
  242.     {
  243.     *   > p:*;
  244.     }
  245.  
  246. Merge items: li,(li2:li)+;
  247.     {
  248.     li > li:;
  249.     li2 > li:;
  250.     }
  251. Remove the paragraph level: li{p{(cont:*)+},?(next:*)+};
  252.     {
  253.          li > li:;
  254.          cont > *;
  255.          next > *;
  256.          }
  257. Remove the Underline: (u{*+})+;
  258.         {
  259.         * > :*;
  260.         }
  261.  
  262. Split items: (li{a:*,(b:*)+})+;
  263.     {
  264.     a > :li.*;
  265.     b > :li.*;
  266.     }
  267.  
  268. Merge lists: ul{li+},(ul{li+})+;
  269.     {
  270.     li > ul:li;
  271.     }
  272.  
  273. Merge lists: ol{li+},(ol{li+})+;
  274.     {
  275.     li > ol:li;
  276.     }
  277.  
  278. Merge lists: dl{(dt|dd)+},(dl{(dt|dd)+})+;
  279.     {
  280.     dt > dl:dt;
  281.     dd > dl:dd;
  282.     }
  283.  
  284. !Paragraph: *{(li{(cont:*)+})+};
  285. !    {
  286. !    cont > :*;
  287. !    }
  288.  
  289. Paragraph: *{(li{(*{?(li{(lev2:*)+})+})+})+};
  290.     {
  291.     lev2 > :*;
  292.     }
  293.  
  294. Paragraphs: (ol{(li{(h1|h2|h3|h4|h5|h6|p|*)+})+})+;
  295.     {
  296.     h1 > :h1;
  297.     h2 > :h2;
  298.     h3 > :h3;
  299.     h4 > :h4;
  300.     h5 > :h5;
  301.     h6 > :h6;
  302.     p > :p;
  303.     * > :p.*;
  304.     }
  305.  
  306. Paragraphs: (ul{(li{(h1|h2|h3|h4|h5|h6|p|*)+})+})+;
  307.     {
  308.     h1 > :h1;
  309.     h2 > :h2;
  310.     h3 > :h3;
  311.     h4 > :h4;
  312.     h5 > :h5;
  313.     h6 > :h6;
  314.     p > :p;
  315.     * > :p.*;
  316.     }
  317.  
  318. Remove two list levels: *{(li{(*{?(li{(lev2:*)+})+})+})+};
  319.     {
  320.     lev2 > :*;
  321.     }
  322.  
  323. ! Forms to/from elements
  324. !!!!!!!!!!!!!!!!!!!!!!!!
  325.  
  326. Enclosing into Form: (h1|h2|h3|h4|h5|h6|p)+;
  327.     {
  328.     h1 > form:h1;
  329.     h2 > form:h2;
  330.     h3 > form:h3;
  331.     h4 > form:h4;
  332.     h5 > form:h5;
  333.     h6 > form:h6;
  334.     p > form:p;
  335.     }
  336.  
  337. Remove the Form: form{?*+};
  338.     {
  339.     * > :*;
  340.     }
  341.  
  342. Remove the submenu: (optgroup{*+})+;
  343.     {
  344.         * > :*;
  345.     }
  346.  
  347. ! Lists to/from elements
  348. !!!!!!!!!!!!!!!!!!!!!!!!
  349.  
  350. Bulleted list: (p|ol|menu|dir|pre|form)+;
  351.        {
  352.         p > ul:<li style=p.style>;
  353.         ol > ul;
  354.         pre > ul:li.pre;
  355.         form > ul:li.form;
  356.         }
  357.  
  358. Numbered list:(p|ul|menu|dir|pre|form)+;
  359.        {
  360.         p > ol:li;
  361.         ul > ol;
  362.         pre > ol:li.pre;
  363.         form > ol:li.form;
  364.         }
  365.  
  366. ! Remove elements
  367. !!!!!!!!!!!!!!!!!!!!!!!!!
  368.  
  369. Remove the division: (div{*+})+;
  370.     {
  371.         * > :*;
  372.     }
  373.  
  374. Remove the Center element: (center{*+})+;
  375.     {
  376.         * > :*;
  377.     }
  378.  
  379. Remove the paragraph level: p{img};
  380.          {
  381.         img > :*;
  382.          }
  383.  
  384. Remove the BlockQuote element: blockquote{*+};
  385.     {
  386.     * > :*;
  387.     }
  388.  
  389. Remove the font element: font{*+};
  390.     {
  391.     * > :*;
  392.     }
  393.  
  394. Remove the span element: span{*+};
  395.     {
  396.     * > :*;
  397.     }
  398.  
  399. Remove the Subscript: sub{*+};
  400.     {
  401.     * > :*;
  402.     }
  403.     
  404. Remove the Superscript: sup{*+};
  405.     {
  406.     * > :*;
  407.     }
  408.     
  409. Remove the Quotation: q{*+};
  410.     {
  411.         * > :*;
  412.     }
  413.  
  414. Remove the BiDi: bdo{*+};
  415.     {
  416.         * > :*;
  417.     }
  418.  
  419. ! Tables to/from elements
  420. !!!!!!!!!!!!!!!!!!!!!!!!!
  421.  
  422. Table: *{(lev1:li{?(*{(lev2:li)+}|elem:*)+})+};
  423.     {
  424.     lev1 > <table border="1">:tr;
  425.     elem > table.tr:td.*;
  426.     lev2 > table.tr:td;
  427.     }
  428.  
  429. Table: dl{(dt|dd)+};
  430.     {
  431.     dt > <table border="1">.tbody:tr.td;
  432.     dd > table.tbody.tr:td;
  433.     }
  434.  
  435. Numbered List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  436.       {
  437.     caption > :ol.li.strong;
  438.     block > :ol;
  439.     tr > ol:li;
  440.     td > ol.li:;
  441.     th > ol.li:;
  442.     td2 > ol.li.ul:li;
  443.     th2 > ol.li.ul:li;
  444.     }
  445.  
  446. Bulleted List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  447.     {
  448.     caption > :ul.li.strong;
  449.     block > :ul;
  450.     tr > ul:li;
  451.     td > ul.li:;
  452.     th > ul.li:;
  453.     td2 > ul.li.ul:li;
  454.     th2 > ul.li.ul:li;
  455.     }
  456.  
  457. Definition List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  458.         {
  459.         caption > :dl.dt;
  460.         block   > :dl;
  461.         td      > dl:dt;
  462.         th      > dl:dt;
  463.         td2     > dl:dd;
  464.         th2     > dl:dd;
  465.         }
  466.  
  467. Vertical table: *+;
  468.     {
  469.     * > <table border="1">:tr.td.*;
  470.     }
  471.  
  472. Horizontal table : *+;
  473.     {
  474.     * > <table border="1">.tr:td.*;
  475.     }
  476.  
  477. Remove the table:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  478.         {
  479.         caption > :div.p;
  480.         block   > :div;
  481.         td      > :div;
  482.         th      > :div;
  483.         td2     > :div;
  484.         th2     > :div;
  485.         }
  486.  
  487. Transpose the table:table{tbody{tr{(td|th)+}|(tr{td2:td|th2:th})+}};
  488.     {
  489.     td > <table border=table.border>:tr.td;
  490.     th > table:tr.td;
  491.     td2 > <table border=table.border>.tr:td;
  492.     th2 > table.tr:td;
  493.     }
  494.  
  495. Heading cell:?(td|th)+,td,?(td|th)+;
  496.     {
  497.     $ChangeToHeadingCell;
  498.     }
  499.  
  500. Data cell:?(td|th)+,th,?(td|th)+;
  501.     {
  502.     $ChangeToDataCell;
  503.     }
  504.  
  505. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  506. ! Global Document transformation tests !
  507. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  508.  
  509. DistrThot: body{*+}
  510.     {
  511.     body >     <table border="0" with="100%">.tbody.tr.<td with="30%">.<a href="http://opera.inrialpes.fr/OPERA/Thot.en.html"><img src="thot.gif" alt="Thot Editor" border="0" align="middle">;
  512.     body > table.tbody.tr.td:<a href="http://opera.inrialpes.fr">.<img src="opera.gif" alt="Opera project" border="0" align="middle">;
  513.     body > table.tbody.tr:td.<img src="guide.gif" alt="Documentation" border="0" align="middle">;
  514.     body > table.tbody.tr.td:h1."Title of the page";
  515.     body > :<table border="0" with="100%">.tbody.tr.<td with="30%">.h2.<a href="Index.html">."Home";
  516.     * > table.tbody.tr:td.*;
  517.     }
  518.